package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Position;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.PositionMapper;
import com.neuedu.studentmanage.service.PositionService;

@Service
@Transactional // 事务处理
public class PositonServiceImpl implements PositionService {

	@Autowired // 自动装配
	private PositionMapper positionMapper;

	@Override
	public List<Position> findAll() {
		return positionMapper.findAll();
	}

	@Override
	public List<Position> findListByPager(Pager<Position> pager) {
		return positionMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Position> pager) {
		return positionMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Position position) {
		Result result = new Result(false, "新增去向失败");
		boolean res = positionMapper.add(position);
		if (res) {
			result = new Result(true, "新增去向成功");
		}
		return result;
	}

	@Override
	public Result edit(Position position) {
		Result result = new Result(false, "修改去向失败");
		boolean res = positionMapper.edit(position);
		if (res) {
			result = new Result(true, "修改去向成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Position> ids) {
		Result result = new Result(false, "删除去向失败");
		boolean res = positionMapper.deleteByIds(ids);
		if (res) {
			result = new Result(true, "删除去向成功");
		}
		return result;
	}

}
